package com.integrance.budgetapp.domain;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "PROFILE")
public class Profile {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "profile_id", nullable = false, unique = true)
	private Long id;

	@Column(name = "first_name", nullable = true, length = 50)
	private String firstName;

	@Column(name = "last_name", nullable = true, length = 50)
	private String lastName;

	@Column(name = "email", nullable = false, length = 60)
	private String email;

	@Column(name = "profile_timestamp", nullable = true)
	private Date timestamp;

	@ManyToOne(optional = false)
	@JoinColumn(name = "user_account_id", nullable = false, updatable = false)
	private UserAccount userAccount;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "profile")		
	private Set<Portfolio> portfolios;
	
	public Profile() {

	}

	public Profile(UserAccount userAccount, String email) {
		this.userAccount = userAccount;
		this.email = email;
	}
	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public Long getId() {
		return id;
	}

	private void setId(Long id) {
		this.id = id;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}
	
	public UserAccount getUserAccount() {
		return userAccount;
	}
	
	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}
	
	public Set getPortfolios() {
		return portfolios;
	}
	
	public void setPortfolios(Set<Portfolio> portfolios) {
		this.portfolios = portfolios;
	}
}
